<template>
  <div class="order-list">
    <order-header title="订单下单中">
      <template v-slot:tip>
        <span>请谨防钓鱼链接或诈骗电话，了解更多></span>
      </template>
    </order-header>
    <div class="wrapper">
      <div class="container">
        <div class="order-box">
          <loading v-if="loading"></loading>
          <div class="order" >
            <div class="order-title">
            <img src="" style="width:32px;height:32px;" 
            
            />
            <span> {{resultText}}</span>
            </div>
            <div class="order-content clearfix">
        
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import OrderHeader from './../components/OrderHeader'
 
  export default{
    name:'order-list',
    components:{
      OrderHeader     
    },
    
    data(){
      return {
         otimer:function(){},
         id:this.$route.params.id,
         resultText:"状态查询中..."
      }
    },
    created(){
         this.timer();
    },
    mounted(){
      this.getOrderStatus();
    },
    methods:{
      getOrderStatus(){
          
         this.axios.get('/order/miaosha/result?productId='+this.id).then((res)=>{
            
            if(res==null){
                this.resultText="无进行中的订单";
                this.destroyed();
              return ;
            }
            if(res==-1){
                this.destroyed();
                this.resultText="秒杀失败";
               // this.$router.push({path:'/product/'+this.id});
            }else if(res>1){
               this.destroyed();
                  this.$router.push({
                  path:'/order/pay',
                  query:{
                    orderId:res
                  }
                }) 
            } 
        })
       },
      timer(){
        this.otimer=setInterval(()=>{
          this.getOrderStatus();
        },3000);

      },
      destroyed() {
        clearInterval(this.otimer)
       }
  
    }
  }
</script>
<style lang="scss">
  @import './../assets/scss/config.scss';
  @import './../assets/scss/mixin.scss';
  .order-list{
    .wrapper{
      background-color:$colorJ;
      padding-top:33px;
      padding-bottom:110px;
      .order-box{
        .order{
          @include border();
          background-color:$colorG;
          margin-bottom:31px;
          &:last-child{
            margin-bottom:0;
          }
          .order-title{
            @include height(74px);
            background-color:$colorK;
            padding:0 43px;
            font-size:16px;
            color:$colorC;
            .item-info{
              span{
                margin:0 9px;
              }
            }
            .money{
              font-size:26px;
              color:$colorB;
            }
          }
          .order-content{
            padding:0 43px;
            .good-box{
              width:88%;
              .good-list{
                display: flex;
                align-items: center;
                height:145px;
                .good-img{
                  width:112px;
                  img{
                    width:100%;
                  }
                }
                .good-name{
                  font-size:20px;
                  color:$colorB;
                }
              }
            }
            .good-state{
              @include height(145px);
              font-size: 20px;
              color:$colorA;
              a{
                color:$colorA;
              }
            }
          }
        }
        .pagination{
          text-align:right;
        }
        .el-pagination.is-background .el-pager li:not(.disabled).active{
          background-color: #FF6600;
        }
        .el-button--primary{
          background-color: #FF6600;
          border-color: #FF6600;
        }
        .load-more,.scroll-more{
          text-align:center;
        }
      }
    }
  }
</style>